package com.slz3.business.module.drawManagement.draGoods.service;

import com.slz3.business.frame.module.Repositorys;
import com.slz3.business.module.drawManagement.draGoods.domain.DraGoods;
import com.slz3.business.module.drawManagement.draGoods.domain.DraGoodsFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

@Slf4j
@Service
public class DraGoodsTransactionalServiceImpl implements DraGoodsTransactionalService {

    @Override
    public DraGoods modify(DraGoods draGoodsNew) {
        Repositorys.draGoods.test();
        Repositorys.draGoods.save(DraGoodsFactory.initBaseFields());
        System.err.println(1/0);
        draGoodsNew.setLastModifyTime(LocalDateTime.now());
        return Repositorys.draGoods.saveAndFlush(draGoodsNew);
    }

    @Override
    public List<DraGoods> batchModify(List<DraGoods> draGoodsList) {
        return Repositorys.draGoods.saveAll(draGoodsList);
    }
}
